home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 259 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: library.erc.clarkson.edu!rpi!not-for-mail
  2. From: Senthil <senthil@genmagic.com>
  3. Newsgroups: comp.lang.c++.moderated,comp.lang.c++
  4. Subject: Re: Meaning of the specifier volatile?
  5. Date: 3 Jan 1996 09:28:27 -0000
  6. Organization: GENERAL MAGIC
  7. Sender: cppmods@netlab.cs.rpi.edu
  8. Approved: kanze@gabi-soft.fr
  9. Message-ID: <4cdi7r$ci9@netlab.cs.rpi.edu>
  10. References: <4c9740$27n@netlab.cs.rpi.edu>
  11. NNTP-Posting-Host: netlab.cs.rpi.edu
  12.  
  13. X-Original-Date: Tue, 02 Jan 1996 15:25:49 -0800
  14.  
  15. Srinivas Vobilisetti wrote:
  16. > X-Original-Date: 31 Dec 1995 01:42:27 GMT
  17. > Hello,
  18. >
  19.  
  20. Concept of volatile can be easily using a simple example:
  21.  
  22. int a
  23.  
  24. a = 1;
  25. a++
  26. if (a==1) {
  27.     ...
  28. }
  29.  
  30. typically compiler loads the value of variable a, into a register of a processor 
  31. before executing 'a++'. and compares the value of register that holds the value 
  32. instead of checking the value at the actual memory location. This optimization is default
  33. in any C compiler. If suppose the location of variable a is a hardware location like
  34. printer port, this optimization won't work, to supress such optimization we add the keyword
  35. volatile, In that case compiler generate instruction to fetch from actual location instead
  36. of fetching value from register.
  37.  
  38.  
  39.  
  40. > I referred to various books on C++ including The C++ Programming Language
  41. > -Bjarne Stroustrup, C++ Primer -Stanley Lipmann, etc.  Nowhere i could find
  42. > exact meaning of the specifier volatile. Thanks in advance for your help. I
  43. > would appreciate the reply at my email address srv@cs.wayne.edu
  44. > Thanks
  45. > Srinivas
  46. > srv@cs.wayne.edu
  47.  
  48.     [ comp.lang.c++.moderated is a moderated newsgroup.  Submit articles ]
  49.     [  to <c++-submit@netlab.cs.rpi.edu>.  The moderation policy can be  ]
  50.     [   retrieved from <http://netlab.cs.rpi.edu/~cppmods/guide.html>.   ]
  51.     [    Moderators can be reached at: c++-request@netlab.cs.rpi.edu.    ]
  52.